package com.sky.demo.aes;


import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import java.nio.charset.StandardCharsets;

/**
 * AES加密方式算法工具类
 */
public class AES {
    /**
     * KEY 随机的后续可更改
     */
    private static final byte[] key ="c909wbtpbrw2otsdgva4albygc5miz6q".substring(0, 16).getBytes(StandardCharsets.UTF_8);
    /**
     * 初始化加密(默认的AES加密方式)
     */
    private static final SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);


    /**
     * 加密
     * @param str 加密之前的字符串
     * @return
     */
    public static String encryptHex(String str){
        return aes.encryptHex(str);
    }

    /**
     * 解密
     * @param str 加密后的字符串
     * @return
     */
    public static String decryptStr(String str){
        return aes.decryptStr(str);
    }

    public static void main(String[] args) {
        String decrypt = decryptStr("b3c4a17d611ebbec114706e5cbb448873fe9900f549227eca21362e248d660e125e7d6a56989dae99497b0807d738a9ad84bb05f88d4ad41dbc3e98dcedb17a9985e5950c313014b3f402d8aa1c3e06f944bc6780c962db4e4b3fd5ce67158efcb0e7f25f7ac20deed1f906ee0861ef4458e70d39ce8670c441609a24b23df4d4a78d6c8f3c6738abc96b3303058fd84d6a676c203856e67775e85dd6769412bb510a8cedb4702c1e2d6230b958b7666967c32bc768b0003bb890e7996929440dccdbe0a062e77e3e7accbbb065633");
        System.out.println(decrypt);
    }
}